package com.wao.product.domain;

import com.wao.base.domain.BaseMultitenantAuditingEntity;
import io.swagger.annotations.ApiModel;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Objects;

/**
 * Value entity.
 *
 * @author Arthur.
 */
@ApiModel(description = "Value entity. @author Arthur.")
@Entity
@Table(name = "product_value")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Value extends BaseMultitenantAuditingEntity {

    private static final long serialVersionUID = 1L;

    @NotNull
    @Size(max = 5000)
    @Column(name = "name", length = 5000, nullable = false)
    private String name;

    @Column(name = "alias")
    private String alias;

    @Column(name = "image")
    private String image;

    @NotNull
    @Column(name = "image_pro", nullable = false)
    private Boolean imagePro;

    @NotNull
    @Column(name = "default_image", nullable = false)
    private Boolean defaultImage;

    @NotNull
    @Column(name = "enabled", nullable = false)
    private Boolean enabled;

    @Column(name = "display_order")
    private Integer displayOrder;

    @Size(max = 8)
    @Column(name = "lang_key", length = 8)
    private String langKey;

    @NotNull
    @Column(name = "category_id", nullable = false)
    private Long categoryId;

    @ManyToOne(optional = false)
    @NotNull
    private Property property;

    public String getName() {
        return name;
    }

    public Value name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAlias() {
        return alias;
    }

    public Value alias(String alias) {
        this.alias = alias;
        return this;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getImage() {
        return image;
    }

    public Value image(String image) {
        this.image = image;
        return this;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Boolean isImagePro() {
        return imagePro;
    }

    public Value imagePro(Boolean imagePro) {
        this.imagePro = imagePro;
        return this;
    }

    public void setImagePro(Boolean imagePro) {
        this.imagePro = imagePro;
    }

    public Boolean isDefaultImage() {
        return defaultImage;
    }

    public Value defaultImage(Boolean defaultImage) {
        this.defaultImage = defaultImage;
        return this;
    }

    public void setDefaultImage(Boolean defaultImage) {
        this.defaultImage = defaultImage;
    }

    public Boolean isEnabled() {
        return enabled;
    }

    public Value enabled(Boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Integer getDisplayOrder() {
        return displayOrder;
    }

    public Value displayOrder(Integer displayOrder) {
        this.displayOrder = displayOrder;
        return this;
    }

    public void setDisplayOrder(Integer displayOrder) {
        this.displayOrder = displayOrder;
    }

    public String getLangKey() {
        return langKey;
    }

    public Value langKey(String langKey) {
        this.langKey = langKey;
        return this;
    }

    public void setLangKey(String langKey) {
        this.langKey = langKey;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public Value categoryId(Long categoryId) {
        this.categoryId = categoryId;
        return this;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public Property getProperty() {
        return property;
    }

    public Value property(Property property) {
        this.property = property;
        return this;
    }

    public void setProperty(Property property) {
        this.property = property;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Value value = (Value) o;
        if (value.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), value.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Value{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", alias='" + getAlias() + "'" +
            ", image='" + getImage() + "'" +
            ", imagePro='" + isImagePro() + "'" +
            ", defaultImage='" + isDefaultImage() + "'" +
            ", enabled='" + isEnabled() + "'" +
            ", displayOrder='" + getDisplayOrder() + "'" +
            ", langKey='" + getLangKey() + "'" +
            ", categoryId='" + getCategoryId() + "'" +
            "}";
    }
}
